package com.dyh.quickdemo.dasync;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.function.Consumer;

/*
@Author=Joey Wheeler
@Date=2021/3/11 17:25
*/
@Service
public class AsyncHandlerFacadeService {

    @Autowired
    AsyncHandlerCenter handlerCenter;

    public void send(AsyncEventContext asyncEventContext){
        AsyncEvent event = new AsyncEvent( this,asyncEventContext);
        ApplicationContextUtil.getApplicationContext().publishEvent(event);
    }

    public void regist(String id,Consumer<?> consumer) {
         handlerCenter.regist(id,consumer);
    }
}
